import 'package:flutter/material.dart';

// ignore: must_be_immutable

//StatelessWidget无状态组件,StatelessWidget
//也就是只是用来展示的,就算数据更新了,视图也不会更新
class MyApp2 extends StatelessWidget {
  MyApp2({super.key, this.age});

  String name = '小美';
  num? age;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      //导航条
      appBar: AppBar(
        title: const Text(
          '下午不睡觉',
          style: TextStyle(color: Colors.white, fontSize: 20),
        ),
        backgroundColor: Colors.pink,
        centerTitle: true,
      ),
      body: Center(
        child: Text(
          '姓名:$name,年龄:$age',
          style: TextStyle(fontSize: 40, color: Colors.amberAccent),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          age = age! + 1;
          print(age);
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}
